<template>
  <div>
    <van-divider>登录</van-divider>
    <van-field v-model="username" label="用户名" placeholder="请输入用户名" />
    <van-field v-model="password" label="密码" placeholder="输入密码" type="password" />
    <van-row type="flex" justify="center" style="padding: 20px">
      <van-col span="24" align="center"><van-button @click="forwardRegister" style="width: 90%; margin: 5px;" type="primary" block="true" round>登录 / 注册</van-button></van-col>
      <van-col span="24" align="center"><van-button style="width: 90%; margin: 5px;" type="danger" block="true" round>退出</van-button></van-col>
    </van-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: "",
      password: ""
    };
  },
  methods: {
    forwardRegister(e) {
      let store = this.$store;
      store.dispatch("user/login", {
        "username": this.username,
        "password": this.password
      })
    }
  },
};
</script>

<style lang="css" scoped>
</style>
